home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Enlighten DSM 1.1
/
SGI EnlightenDSM 1.1.iso
/
sco5x
/
install
/
bin
/
e_putrc
< prev
next >
Wrap
Text File
|
1998-07-01
|
8KB
|
338 lines
#!/bin/sh
#
# Script: e_putrc
#
# Add a reference to start_enl_daemons to the appropriate rc file.
#
# Copyright (c) 1990-1998 Enlighten Software Solutions, Inc.
# All Rights Reserved
PATH=/bin:/usr/bin:/etc:/usr/ucb:/usr/bsd:/usr/etc:$PATH
export PATH
appName=`basename $0`
errorCheck () {
if [ $? -ne 0 ] ; then
echo "$appName: Fatal: Could not add Enlighten reference to rc file." 1>&2
exit 1
fi
}
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# build_rc - Build a SVr5 compliant rc2.d script.
# (currently just used for HP-UX 10.x)
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
buildrc () {
if [ -f "$LINK_DIR/$LINK_FILE" ] ; then
mv $LINK_DIR/$LINK_FILE /tmp/$LINK_FILE.old ; errorCheck
echo "$appName: Archived $LINK_DIR/$LINK_FILE to /tmp/$LINK_FILE.old"
fi
if [ -f "$LINK_DIR_STOP/$LINK_FILE_STOP" ] ; then
mv $LINK_DIR_STOP/$LINK_FILE_STOP /tmp/$LINK_FILE_STOP.old ; errorCheck
echo "$appName: Archived $LINK_DIR_STOP/$LINK_FILE_STOP to /tmp/$LINK_FILE_STOP.old"
fi
if [ -f "$RC_DIR/$RC_FILE" ] ; then
mv $RC_DIR/$RC_FILE /tmp/$RC_FILE.old ; errorCheck
echo "$appName: Archived $RC_DIR/$RC_FILE to /tmp/$RC_FILE.old"
fi
cat << eof > $RC_DIR/$RC_FILE
#!/bin/sh
# Script: $RC_DIR/$RC_FILE
# Copyright (c) 1990-1998 Enlighten Software Solutions, Inc.
PATH=/sbin:/usr/sbin:/bin:/usr/bin ; export PATH
# Find start_enl_daemons.
enlDir=\`egrep "^enlighten=" /etc/enlighten | cut "-d=" -f2-\`
emdDir=\`egrep "^emd_dir=" /etc/enlighten | cut "-d=" -f2-\`
startLic=\$emdDir/FLEXlm/start_dsmld
stopLic=\$emdDir/FLEXlm/stop_dsmld
startDaemons=\$enlDir/bin/start_enl_daemons
stopDaemons=\$enlDir/bin/stop_enl_daemons
logFile=\$enlDir/logs/startup.log
rc=0
case \$1 in
start_msg)
echo "Start EnlightenDSM daemons"
;;
stop_msg)
echo "Stop EnlightenDSM daemons"
;;
start)
if [ -n "\$emdDir" ] ; then
if [ ! -f \$startLic ] ; then
echo "\$0: \$startLic was missing."
rc=1
elif [ ! -x \$startLic ] ; then
echo "\$0: \$startLic was not executible."
rc=1
else
echo "Starting $startLic..."
nohup sh -c "su dbenl -c '\$startLic' > \$logFile 2>&1 &"
rc=\$?
fi
fi
if [ ! -f \$startDaemons ] ; then
echo "\$0: \$startDaemons was missing."
rc=1
elif [ ! -x \$startDaemons ] ; then
echo "\$0: \$startDaemons was not executible."
rc=1
else
echo "Starting EnlightenDSM daemons..."
nohup sh -c "\$startDaemons > \$logFile 2>&1 &"
rc=\$?
fi
;;
stop)
if [ -n \$emdDir ] ; then
if [ ! -f \$stopLic ] ; then
echo "\$0: \$stopLic was missing."
rc=1
elif [ ! -x \$stopLic ] ; then
echo "\$0: \$stopLic was not executible."
rc=1
else
su dbenl -c "\$stopLic"
rc=\$?
fi
fi
if [ ! -f \$stopDaemons ] ; then
echo "\$0: \$stopDaemons was missing."
rc=1
elif [ ! -x \$stopDaemons ] ; then
echo "\$0: \$stopDaemons was not executible."
rc=1
else
\$stopDaemons
rc=\$?
fi
;;
*)
echo "\$0: Usage: \$0 {start|stop}"
;;
esac
exit \$rc
eof
if [ -n "$LINK_DIR" ] ; then
ln -s $RC_DIR/$RC_FILE $LINK_DIR/$LINK_FILE
errorCheck
echo $LINK_DIR/$LINK_FILE >> $enl_manifest
fi
if [ -n "$LINK_DIR_STOP" ] ; then
ln -s $RC_DIR/$RC_FILE $LINK_DIR_STOP/$LINK_FILE_STOP
errorCheck
echo $LINK_DIR_STOP/$LINK_FILE_STOP >> $enl_manifest
fi
echo $RC_DIR/$RC_FILE >> $enl_manifest
}
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# add2rc - add the comment and nohup lines to the RC file
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
add2rc () {
if [ -f $RC_DIR/$RC_FILE ] ; then
daemonName=`basename $startDaemonsScript`
mv $RC_DIR/$RC_FILE $RC_DIR/$RC_FILE.old ; errorCheck
echo "$appName: Archived $RC_DIR/$RC_FILE to $RC_DIR/$RC_FILE.old.";
egrep -v "S92startenl|$daemonName" $RC_DIR/$RC_FILE.old \
> $RC_DIR/$RC_FILE
errorCheck
else
touch $RC_DIR/$RC_FILE
fi
if [ "$start_lic" -eq 1 ] ; then
echo "echo Invoking $lic_script..." >> $RC_DIR/$RC_FILE
echo "nohup sh -c 'su dbenl -c \"$lic_script\" > $LOG 2>&1 &' " >> $RC_DIR/$RC_FILE
errorCheck
fi
if [ -z "`grep $startDaemonsScript $RC_DIR/$RC_FILE`" ] ; then
echo "echo Invoking $startDaemonsScript..." >> $RC_DIR/$RC_FILE
echo "nohup sh -c '$startDaemonsScript > $LOG 2>&1 &' " >> $RC_DIR/$RC_FILE
errorCheck
fi
}
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# HP-UX 9.0x version of add2rc
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
hpadd2rc() {
if [ "$start_lic" -eq 1 ] ; then
if [ -z "`grep $lic_script $RC_DIR/$RC_FILE`" ] ; then
daemonName=`basename $startDaemonsScript`
mv $RC_DIR/$RC_FILE $RC_DIR/$RC_FILE.old
errorCheck
egrep -v "$daemonName|$lic_script|S92startenl" $RC_DIR/$RC_FILE.old \
> $RC_DIR/$RC_FILE
errorCheck
awk " /^localrc\(\)/ { f = 1 }
f == 1 && /^}/ { print \"\\n\\techo Invoking $lic_script...\\n\\tsu dbenl -c '$lic_script > $LOG 2>&1 &' \" ; f = 0 }
{ print }
" < $RC_DIR/$RC_FILE > $RC_DIR/$RC_FILE.new
mv $RC_DIR/$RC_FILE.new $RC_DIR/$RC_FILE
errorCheck
fi
fi
if [ -z "`grep $startDaemonsScript $RC_DIR/$RC_FILE`" ] ; then
daemonName=`basename $startDaemonsScript`
mv $RC_DIR/$RC_FILE $RC_DIR/$RC_FILE.old
errorCheck
egrep -v "$daemonName|S92startenl" $RC_DIR/$RC_FILE.old \
> $RC_DIR/$RC_FILE
errorCheck
awk " /^localrc\(\)/ { f = 1 }
f == 1 && /^}/ { print \"\\n\\techo Invoking $startDaemonsScript...\\n\\tnohup sh -c '$startDaemonsScript > $LOG 2>&1 &' \" ; f = 0 }
{ print }
" < $RC_DIR/$RC_FILE > $RC_DIR/$RC_FILE.new
mv $RC_DIR/$RC_FILE.new $RC_DIR/$RC_FILE
errorCheck
fi
}
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Start of e_putrc
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
if [ -z "$ENLIGHTEN" ] ; then
ENLIGHTEN=`egrep "^enlighten=" /etc/enlighten | cut '-d=' -f2-`
fi
if [ -z "$ENLIGHTEN" -o ! -d $ENLIGHTEN/bin ] ; then
#
# Maybe it's an EMD-only installation.
#
EMD_DIR=`egrep "^emd_dir=" /etc/enlighten | cut '-d=' -f2-`
if [ -z "$EMD_DIR" -o ! -d $EMD_DIR/bin ] ; then
echo "$appName: Fatal: The ENLIGHTEN variable was not set correctly." 1>&2
exit 1
else
ENLIGHTEN=$EMD_DIR ; export ENLIGHTEN
fi
fi
enl_manifest=${ENLIGHTEN}/manifest
#
# Find emd\-dir to see if licensing should be started
#
if [ -z "$EMD_DIR" ] ; then
EMD_DIR=`egrep "^emd_dir=" /etc/enlighten | cut '-d=' -f2-`
fi
if [ -n "$EMD_DIR" ] ; then
flex_dir="$EMD_DIR/FLEXlm"
lic_script="$flex_dir/start_dsmld"
if [ ! -f "$lic_script" ] ; then
echo "$appName:Unable to find $lic_script."
start_lic=0
else
start_lic=1
fi
else
start_lic=0
fi
if [ -d $ENLIGHTEN/logs ] ; then
LOG=$ENLIGHTEN/logs/startup.log
else
LOG=/tmp/enlighten.log
fi
startDaemonsScript=$ENLIGHTEN/bin/start_enl_daemons
stopDaemonsScript=$ENLIGHTEN/bin/stop_enl_daemons
if [ ! -x $startDaemonsScript ] ; then
echo "$appName: Fatal: The script $startDaemonsScript is missing." 1>&2
exit 1
fi
case `uname -s` in
OSF1 )
RC_DIR=/sbin/init.d
RC_FILE=enlighten
LINK_FILE=S920enlighten
LINK_DIR=/sbin/rc3.d
LINK_FILE_STOP=K12enlighten
LINK_DIR_STOP=/sbin/rc0.d
buildrc
;;
HP-UX )
case `uname -r` in
?.10.* )
RC_DIR=/sbin/init.d
RC_FILE=enlighten
LINK_FILE=S920enlighten
LINK_DIR=/sbin/rc2.d
LINK_FILE_STOP=K12enlighten
LINK_DIR_STOP=/sbin/rc0.d
buildrc
;;
* )
RC_DIR=/etc
RC_FILE=rc
hpadd2rc
;;
esac
;;
IRIX* )
RC_DIR=/etc/init.d
RC_FILE=enlighten
LINK_FILE=S920enlighten
LINK_DIR=/etc/rc2.d
LINK_FILE_STOP=K12enlighten
LINK_DIR_STOP=/etc/rc0.d
buildrc
;;
AIX )
RC_DIR=/etc
RC_FILE=rc.nfs
add2rc
;;
* )
if [ -d /etc/rc2.d ] ; then
RC_DIR=/etc/rc2.d
RC_FILE=S920enlighten
buildrc
else
RC_DIR=/etc
RC_FILE=rc.local
add2rc
fi
;;
esac
chmod 744 $RC_DIR/$RC_FILE
errorCheck
echo "$appName: Enlighten reference successfully added to $RC_DIR/$RC_FILE"
exit 0